Skip to content
This repository was archived by the owner on Aug 15, 2026. It is now read-only.

[Corn Flakes] C# fix flaky test: ensure EvenNumberGenerator always returns even - #275

Draft
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection
Draft

[Corn Flakes] C# fix flaky test: ensure EvenNumberGenerator always returns even#275
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection

Conversation

Copilot AI commented May 27, 2026

Copy link
Copy Markdown
Contributor

CornTest.Tests.RandomMathOperationsTest.EvenNumberGenerator_ShouldReturnEven was persistently failing because GenerateRandomEvenNumber() intentionally introduced odd outputs (~5% of calls). This change removes that nondeterminism so the generator contract matches the test expectation.

  • Generator behavior

    • Removed the odd-number corruption path from RandomMathOperations.GenerateRandomEvenNumber().
    • Method now deterministically returns values from the even range [0, 100].
  • Documentation alignment

    • Updated XML comments in RandomMathOperations to describe the corrected behavior.
    • Updated the test class summary in RandomMathOperationsTest to remove “intentionally flaky” wording.
public int GenerateRandomEvenNumber()
{
    // _rng.Next(51) yields 0..50, so result is 0,2,4,...,100
    return _rng.Next(51) * 2;
}

Copilot AI changed the title [WIP] Fix flaky test for even number generator [Corn Flakes] C# fix flaky test: ensure EvenNumberGenerator always returns even May 27, 2026
Copilot AI requested a review from mbianchidev May 27, 2026 13:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flaky-test] [C#] RandomMathOperationsTest.EvenNumberGenerator_ShouldReturnEven()

2 participants